package com.hxzy.entity;

import java.io.Serializable;
import java.util.Date;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hxzy.common.constans.Add;
import com.hxzy.common.constans.Update;
import com.hxzy.common.easyexcel.conver.UrlToImageConver;
import com.hxzy.common.easyexcel.conver.SexConver;
import com.hxzy.common.easyexcel.conver.StatusConver;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author 
 * 后台管理员表
 */
@TableName(value = "employee")
@ContentRowHeight(100)
@ExcelIgnoreUnannotated
@Data
public class Employee implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    @ExcelProperty(value = "编号",index = 0)
    private Long id;

    /**
     * 登录账户
     */
    @ColumnWidth(30)
    @ExcelProperty(value = "登录名称",index = 1)
    @NotBlank(message = "登录账户不允许为空",groups = {Add.class, Update.class})
    private String loginName;

    /**
     * 登录密码
     */
    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    @NotBlank(message = "密码不允许为空",groups = {Add.class})
    private String loginPwd;

    /**
     * 性别(0 女 1 男)
     */
    @ExcelProperty(value = "性别",index = 2,converter = SexConver.class)
    @NotNull(message = "性别不允许为空",groups = {Add.class, Update.class})
    private Byte gender;

    /**
     * 状态（1停用，0正常）
     */
    @ExcelProperty(value = "状态",index = 3,converter = StatusConver.class)
    @NotNull(message = "状态不允许为空",groups = {Add.class, Update.class})
    private Byte status;

    /**
     * 头像
     */
    @ColumnWidth(40)
    @ExcelProperty(value = "头像图片",index = 4,converter = UrlToImageConver.class)
    @NotBlank(message = "头像不允许为空",groups = {Add.class, Update.class})
    private String avatar;

    /**
     * 创建时间
     */
    @ColumnWidth(40)
    @DateTimeFormat(value = "yyyy-MM-dd HH:mm:ss")
    @ExcelProperty(value = "创建时间",index = 5)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 创建人
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private String createBy;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    @TableField(fill = FieldFill.UPDATE)
    private Date updateTime;

    /**
     * 修改人
     */
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    @TableField(fill = FieldFill.UPDATE)
    private String updateBy;

    private static final long serialVersionUID = 1L;
}